package shuati.shuzimali;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * @author : LdLtd
 * @Date : 2024/4/15
 * @Description:从1~n中选出组合结果为m的所有组合，按字典序输出
 * 如 5 5
 * 输出
 * 1 4
 * 2 3
 * 5
 */
public class c2401 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        List<List<Integer>> res=new ArrayList<>();
        dfs(res,new ArrayList<>(),n,m,1);
        for (List<Integer> list : res) {
            for (Integer i : list) {
                System.out.print(i+" ");
            }
            System.out.println();
        }
    }
    public static void dfs(List<List<Integer>> res, List<Integer> t, int n, int r, int s){
        if(r<0) return;
        else if(r==0){
            res.add(new ArrayList<>(t));
            return;
        }else {
            for (int i = s; i <=n; i++) {
                t.add(i);
                dfs(res,t,n,r-i,i+1);
                t.remove(t.size()-1);
            }
        }
    }
}
